package com.web.music.model;

/**
 * This is a registry of persistent entities used in a system.
 * It is used in:
 *  	- PersistenceHelperImpl.deleteEverything() to clean DB.
 *  	- PersistenceHelperImplTest to create instances of persistent objects
 */
public enum PersistentEntityType 
{
	ALBUM(Album.class, null),
	
	// Artist is abstract class and instances of that class cannot be created
	// Therefore we specify concrete sub-classes here, which will be used to create objects
	@SuppressWarnings ("unchecked")
	ARTIST(Artist.class, new Class[]{Singer.class, MusicBand.class}),
	
	PERSON(Person.class, null),
	GENRE(Genre.class, null),
	TRACK(Track.class, null);
	
	PersistentEntityType(Class<? extends PersistentEntity> clazz, Class<? extends PersistentEntity>[] subClasses){
		this.clazz = clazz;
		this.subClasses = subClasses;
	}
	
	private Class<? extends PersistentEntity> clazz;
	
	public Class<? extends PersistentEntity> getObjectClass(){
		return this.clazz;
	}
	
	private Class<? extends PersistentEntity>[] subClasses;
	
	public Class<? extends PersistentEntity>[] getSubClasses() {
		return subClasses;
	}
}
